package cn.hfatec.shms.web.vip.vipXzb.service;

import java.util.List;
import java.util.HashMap;


import cn.hfatec.shms.advice.annotation.OracleDataSource;
import cn.hfatec.shms.web.xh.xhHcb.model.XhHcb;
import cn.hfatec.shms.web.xh.xhHcb.model.XhHcbParams;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.hfatec.base.BaseDao;
import cn.hfatec.Page;
import cn.hfatec.Table;
import cn.hfatec.shms.web.vip.vipXzb.model.VipXzb;
import cn.hfatec.shms.web.vip.vipXzb.dao.VipXzbDao;
import cn.hfatec.shms.web.vip.vipXzb.model.VipXzbParams;

import javax.annotation.Resource;



/**
 *
 * @author hfatec
 * @version 1.0
 *
 * the JAVA code is generate by middlegen
 *
 */
@Service("VipXzbService")
public class VipXzbService {

    public static final String BEAN_ID = "VipXzbService";

    //注入Dao层
    @Resource(name = "VipXzbDao")
    private VipXzbDao vipXzbDao;

    //注入BaseDao
    @Resource(name = "BaseDao")
    private BaseDao baseDao;

    /**
     *
     * 查询数据
     *
     * @param vipXzbParams
     *
     *
     */
    @Transactional
    @OracleDataSource
    public Table queryVipXzbTable(VipXzbParams vipXzbParams,Page page){

        HashMap<String, Object> params = new HashMap<String, Object>();
        if (null == page) page = new Page();
        //起始点
        int offset = page.getPageSize() * (page.getCurrentPage() - 1)+1;
        //查询的记录数
        int limit = offset + page.getPageSize()-1;
        vipXzbParams.setStartPage(offset);
        vipXzbParams.setEndPage(limit);
        VipXzb vipXzb =getVipXzb(vipXzbParams);
        if (vipXzb != null) {
            page.setTotalPage(vipXzb.getTotal() / 10 + 1);
            page.setTotalSize(vipXzb.getTotal());
        } else {
            page.setTotalPage(0);
            page.setTotalSize(0);
        }
        params.put("params", vipXzbParams);
        return baseDao.queryTableByPageOracle("queryVipXzb", params, page);
    }
    /**
     *
     * 根据ID获取数据
     *
     *
     */
    @Transactional
    @OracleDataSource
    public VipXzb getVipXzb(VipXzbParams vipXzbParams) {

        return vipXzbDao.getVipXzbId(vipXzbParams);
    }
}